<template>
  <div id="app">
    <el-form :model="student" label-width="100px">

      <el-form-item label="姓名" prop="name">
        <el-input v-model="student.name"></el-input>
      </el-form-item>



      <el-form-item label="密码">
        <el-input v-model="student.pwd"></el-input>
      </el-form-item>


      <el-form-item label="学号">
        <el-input v-model="student.stuNo"  ></el-input>
      </el-form-item>

      <el-form-item label="班级">
        <el-select v-model="student.cid">
          <el-option v-for="(item,index) in classList" :key="index" :label="item.name" :value="item.id"></el-option>
        </el-select>
      </el-form-item>


      <el-form-item>
        <el-button type="primary" @click.prevent="test">保存</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
    export default {
      data(){
        return {
          student:{},
          classList:[]
        }
      },
      created(){
        this.axios.get("/class/selectAll").then(resp=>{
          this.classList=resp.data;
        })
      },
      methods:{
        test(){
            this.$confirm("是否确认提交","保存提示").then(()=>{
              this.axios.post("/student/add",this.student).then((resp)=>{
                  this.$message.success("保存成功！");
                  this.$router.push("/student/StudentList")
                });
            });
        }
      }
    }
</script>


<style scoped>

</style>
